﻿using B.S.Procurement.Domain;
using B.S.Procurement.Error;
using B.S.Procurement.Read.Api.Application.Command.VendorModelCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Procurement.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class VendorController : ControllerBase
    {
        private readonly IMediator mediator;

        public VendorController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 查询供应商信息(下拉)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<VendorModel>>> GetVendor([FromQuery] GetVendorModelCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 查询供应商信息(分页)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<List<VendorModel>>> QueryVendor([FromQuery] QueryVendorModelCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 查询供应商信息(单条反填)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<VendorModel>>> ShowVendor([FromQuery] ShowVendorModelCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
